﻿@using Smartstore.Core.Checkout.Tax
 
@model TaxSettingsModel

@{
    ViewBag.Title = T("Admin.Configuration.Settings.Tax").Value;
    Layout = "_SettingLayout";
}

<form asp-action="Tax">

    <div class="section-header">
        <div class="title">
            @T("Admin.Configuration.Settings.Tax")
        </div>
        <div class="options">
            <button type="submit" name="save" value="save" class="btn btn-warning">
                <i class="fa fa-check"></i>
                <span>@T("Admin.Common.Save")</span>
            </button>
        </div>
    </div>

    @await Component.InvokeAsync("StoreScope")

    <div asp-validation-summary="All"></div>

    <div class="adminContent">
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="PricesIncludeTax" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="PricesIncludeTax"></setting-editor>
                <span asp-validation-for="PricesIncludeTax"></span>
            </div>
        </div>

        @* Not relevant for european market but we have to deal with this option later. *@
        @*<div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="AllowCustomersToSelectTaxDisplayType" />
            </div>
            <div class="adminData">
                @Html.CheckBoxFor(model => model.AllowCustomersToSelectTaxDisplayType, new { data_toggler_for = "#pnlTaxDisplayType" })
                <span asp-validation-for="AllowCustomersToSelectTaxDisplayType"></span>
            </div>
        </div>*@

        <div class="adminRow" id="pnlTaxDisplayType">
            <div class="adminTitle">
                <smart-label asp-for="TaxDisplayType" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="TaxDisplayType"></setting-editor>
                <span asp-validation-for="TaxDisplayType"></span>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="DisplayTaxSuffix" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="DisplayTaxSuffix"></setting-editor>
                <span asp-validation-for="DisplayTaxSuffix"></span>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="DisplayTaxRates" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="DisplayTaxRates"></setting-editor>
                <span asp-validation-for="DisplayTaxRates"></span>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="HideZeroTax" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="HideZeroTax"></setting-editor>
                <span asp-validation-for="HideZeroTax"></span>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="HideTaxInOrderSummary" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="HideTaxInOrderSummary"></setting-editor>
                <span asp-validation-for="HideTaxInOrderSummary"></span>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="ShowLegalHintsInProductList" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="ShowLegalHintsInProductList"></setting-editor>
                <span asp-validation-for="ShowLegalHintsInProductList"></span>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="ShowLegalHintsInProductDetails" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="ShowLegalHintsInProductDetails"></setting-editor>
                <span asp-validation-for="ShowLegalHintsInProductDetails"></span>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="ShowLegalHintsInFooter" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="ShowLegalHintsInFooter"></setting-editor>
                <span asp-validation-for="ShowLegalHintsInFooter"></span>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminSeparator">
                <hr />
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="TaxBasedOn" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="TaxBasedOn"></setting-editor>
                <span asp-validation-for="TaxBasedOn"></span>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="DefaultTaxAddress" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="DefaultTaxAddress">
                    <editor asp-for="DefaultTaxAddress" />
                </setting-editor>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminSeparator">
                <hr />
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="AuxiliaryServicesTaxingType" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="AuxiliaryServicesTaxingType"></setting-editor>
                <span asp-validation-for="AuxiliaryServicesTaxingType"></span>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="ShippingIsTaxable" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="ShippingIsTaxable" data-toggler-for="#pnlShippingIsTaxable"></setting-editor>
                <span asp-validation-for="ShippingIsTaxable"></span>
            </div>
        </div>
        <div id="pnlShippingIsTaxable">
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="ShippingPriceIncludesTax" />
                </div>
                <div class="adminData">
                    <setting-editor asp-for="ShippingPriceIncludesTax"></setting-editor>
                    <span asp-validation-for="ShippingPriceIncludesTax"></span>
                </div>
            </div>
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="ShippingTaxClassId" />
                </div>
                <div class="adminData">
                    <setting-editor asp-for="ShippingTaxClassId">
                        <select asp-for="ShippingTaxClassId" asp-items="ViewBag.ShippingTaxCategories" asp-placeholder="@T("Common.PleaseSelect")"></select>
                    </setting-editor>
                    <span asp-validation-for="ShippingTaxClassId"></span>
                </div>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="PaymentMethodAdditionalFeeIsTaxable" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="PaymentMethodAdditionalFeeIsTaxable" data-toggler-for="#pnlPaymentMethodAdditionalFeeIsTaxable"></setting-editor>
                <span asp-validation-for="PaymentMethodAdditionalFeeIsTaxable"></span>
            </div>
        </div>
        <div id="pnlPaymentMethodAdditionalFeeIsTaxable">
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="PaymentMethodAdditionalFeeIncludesTax" />
                </div>
                <div class="adminData">
                    <setting-editor asp-for="PaymentMethodAdditionalFeeIncludesTax"></setting-editor>
                    <span asp-validation-for="PaymentMethodAdditionalFeeIncludesTax"></span>
                </div>
            </div>
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="PaymentMethodAdditionalFeeTaxClassId" />
                </div>
                <div class="adminData">
                    <setting-editor asp-for="PaymentMethodAdditionalFeeTaxClassId">
                        <select asp-for="PaymentMethodAdditionalFeeTaxClassId" asp-items="ViewBag.PaymentMethodAdditionalFeeTaxCategories" asp-placeholder="@T("Common.PleaseSelect")"></select>
                    </setting-editor>
                    <span asp-validation-for="PaymentMethodAdditionalFeeTaxClassId"></span>
                </div>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminSeparator">
                <hr />
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="EuVatEnabled" />
            </div>
            <div class="adminData">
                <setting-editor asp-for="EuVatEnabled" data-toggler-for="#pnlEuVat"></setting-editor>
                <span asp-validation-for="EuVatEnabled"></span>
            </div>
        </div>
        <div id="pnlEuVat">
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="EuVatShopCountryId" />
                </div>
                <div class="adminData">
                    <setting-editor asp-for="EuVatShopCountryId">
                        <editor asp-for="EuVatShopCountryId"
                                asp-template="Countries"
                                asp-additional-viewdata='new { placeholder = T("Admin.Address.SelectCountry").Value }' />
                    </setting-editor>
                    <span asp-validation-for="EuVatShopCountryId"></span>
                </div>
            </div>
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="EuVatAllowVatExemption" />
                </div>
                <div class="adminData">
                    <setting-editor asp-for="EuVatAllowVatExemption"></setting-editor>
                    <span asp-validation-for="EuVatAllowVatExemption"></span>
                </div>
            </div>
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="EuVatUseWebService" />
                </div>
                <div class="adminData">
                    <setting-editor asp-for="EuVatUseWebService"></setting-editor>
                    <span asp-validation-for="EuVatUseWebService"></span>
                </div>
            </div>
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="EuVatEmailAdminWhenNewVatSubmitted" />
                </div>
                <div class="adminData">
                    <setting-editor asp-for="EuVatEmailAdminWhenNewVatSubmitted"></setting-editor>
                    <span asp-validation-for="EuVatEmailAdminWhenNewVatSubmitted"></span>
                </div>
            </div>
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="VatRequired" />
                </div>
                <div class="adminData">
                    <setting-editor asp-for="VatRequired"></setting-editor>
                    <span asp-validation-for="VatRequired"></span>
                </div>
            </div>
        </div>
    </div>
</form>

<script sm-target-zone="Scripts" data-origin="TaxSettings">
    $(function() {
		$("#@Html.IdFor(model => model.ShippingIsTaxable)").click(updateAuxiliaryServicesTaxCategories);
		$("#@Html.IdFor(model => model.PaymentMethodAdditionalFeeIsTaxable)").click(updateAuxiliaryServicesTaxCategories);
		$('#@Html.IdFor(model => model.AuxiliaryServicesTaxingType)').change(updateAuxiliaryServicesTaxCategories).trigger('change');
	});

	function updateAuxiliaryServicesTaxCategories() {
		var showCategories = ($('#@Html.IdFor(model => model.AuxiliaryServicesTaxingType)').val() === '@((int)AuxiliaryServicesTaxType.SpecifiedTaxCategory)'),
			shippingIsTaxable = $('#@Html.IdFor(model => model.ShippingIsTaxable)').is(':checked'),
			paymentFeeIsTaxable = $('#@Html.IdFor(model => model.PaymentMethodAdditionalFeeIsTaxable)').is(':checked');

		$('#pnlShippingTaxClass').toggle(showCategories && shippingIsTaxable);
		$('#pnlPaymentMethodAdditionalFeeTaxClass').toggle(showCategories && paymentFeeIsTaxable);
	}
</script>